
const setCookie = (name, value, time) => {
    document.cookie = name + "=" + escape(value) + ";expires=" + time;
}
const getCookie2 = (name) => {
    let arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null;
}
const delCookie = (name) => {

    let exp = new Date();
    exp.setTime(exp.getTime() - 1);
    let cval = getCookie2(name);
    if (cval != null)
        document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}
export {
    setCookie,
    delCookie
}